<template>
  <jy-dialog :title="title" :visible.sync="open" width="40%" append-to-body>
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="桩号" v-if="syType == 131">
        <el-input v-model="form.zhuangh" placeholder="请输入桩号"></el-input>
      </el-form-item>
      <el-form-item label="结构物名称" v-if="syType == 131">
        <el-input v-model="form.jiegwmc" placeholder="请输入结构物名称"></el-input>
      </el-form-item>
      <el-form-item label="层位" v-if="syType == 131">
        <el-input v-model="form.cengw" placeholder="请输入层位"></el-input>
      </el-form-item>
      <el-form-item label="墩柱/台身号" v-if="syType == 30">
        <el-input v-model="form.dunztsh" placeholder="请输入墩柱/台身号"></el-input>
      </el-form-item>
      <el-form-item label="测点起点位置" v-if="syType == 30">
        <el-input v-model="form.cedqdwz" placeholder="请输入测点起点位置"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button size="small" type="primary" :disabled="printLoading" @click="submit">保 存</el-button>
      <el-button size="small" @click="cancel">关 闭</el-button>
    </div>
  </jy-dialog>
</template>
  <script>
import { getTstjSybj, tstjSaveSybj } from "@/api/syrw/testMarkView";

export default {
  name: "testMarkView",
  data() {
    return {
      loading: false,
      // 弹出层标题
      title: "试验标记",
      // 是否显示弹出层
      open: false,
      isPdf: false,
      printLoading: false,
      form: {},
      syType: "",
      reportId: ""
    };
  },
  created() {},
  mounted() {},
  methods: {
    init(row) {
      if (!row.reportId && !row.syType) {
        return;
      }
      this.form = {};
      this.reportId = row.reportId;
      this.syType = row.syType;
      this.$nextTick(() => {
        this.getTstjSybjData(row);
      });
    },
    getTstjSybjData(row) {
      getTstjSybj(row.reportId).then((res) => {
        this.form = res.data;
        this.open = true;
      });
    },
    submit() {
      this.printLoading = true;
      tstjSaveSybj({
        ...this.form,
        reportId: this.reportId,
        syType: this.syType
      }).then((res) => {
        this.printLoading = false;
        if (res.code == 200) {
          this.$message.success("试验标记保存成功！");
          this.open = false;
        }
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
    }
  }
};
</script>
  <style lang="scss" scoped>
</style>
  